
export interface TabbarState {
    selectedIndex: number
}

export default {
    namespace: "tabbar",
    state: {
        selectedIndex: 0
    },
    reducers: {
        setState(state: TabbarState, { payload }) {
            return {...state, ...payload}
        }
    },

    effects: {
        *setSelectedIndex({ payload }, { put, select }) {

            let tabbar: TabbarState = yield select(state => state.cart)
            if (tabbar.selectedIndex == payload) {
                return
            }

            yield put({
                type: "setState",
                payload: {
                    selectedIndex: payload
                }
            })
        },
    }
}